import { http } from './service.js'

//家长端
export const login = (redirect) => {
	let host = window.location.host;
	return http.request({
		url: '/wx/api/portal/login?redirect=' + encodeURIComponent(redirect),
		method: 'POST',
	})
}
export const loginParentByPsw = (mobile, password) => {
	console.log(password);
	return http.request({
		url: '/wx/api/portal/phone_pass_login',
		method: 'POST',
		params: {
			'mobile': mobile,
			'password': password,
		}
	})
}

//家长 验证码登陆
export const loginP = (mobile, smsCode) => {
	return http.request({
		url: '/wx/api/portal/verifylogin',
		method: 'POST',
		params: {
			'mobile': mobile,
			'smsCode': smsCode,
		}
	})
}
// 获取图片验证码
export const getImageVerifyCode = (username, timestamp) => {
	return `/wx/api/portal/image_verify_code?mobile=${username}&timestamp=${timestamp}` 
}

//发送验证码
export const sendLoginVerifySms = (params) => {
	return http.request({
		url: '/wx/api/portal/send_login_verify_sms',
		method: 'POST',
		params: params
	})
}
//获取当前家长信息
export const getParentInfo = () => {
	return http.request({
		url: '/wx/api/user/info',
		method: 'GET',
	})
}

export const sendBindCode = (mobile) => {
	return http.request({
		url: '/wx/api/user/send_bind_code',
		method: 'POST',
		params: { mobile }
	})
}

export const userBind = (data) => {
	return http.request({
		url: '/wx/api/user/bind',
		method: 'POST',
		params: data
	})
}

export const userDebind = () => {
	return http.request({
		url: '/wx/api/user/debind',
		method: 'POST',
	})
}

export const getBabylist = () => {
	return http.request({
		url: '/wx/api/user/babylist',
		method: 'GET',
	})
}

export const setDefaultBaby = (babyId) => {
	return http.request({
		url: '/wx/api/user/setdefaultbaby',
		method: 'POST',
		params: {
			'babyId': babyId
		}
	})
}
// 获取课时余额
export const getChildrenBalance = (params) => {
	return http.request({
		url: '/wx/api/nurseryInfoRecord/getBalance',
		method: 'POST',
		params
	})
}



//教师端
export const loginTch = (mobile, password) => {
	return http.request({
		url: '/pad/un_login/phone_pass_login',
		method: 'POST',
		params: {
			'mobile': mobile,
			'password': password,
		}
	})
}
//获取教师信息
export const getTeacherInfo = () => {
	return http.request({
		url: '/pad/teacher/info',
		method: 'POST',
	})
}
//修改密码
export const modifyPassword = (params) => {
	return http.request({
		url: '/web/un_login/modify_password',
		method: 'POST',
		params: params
	})
}
//忘记密码
export const forgetPassword = (params) => {
	console.log(params)
	return http.request({
		url: '/web/un_login/forget_password',
		method: 'POST',
		params: params
	})
}
export const sendCode = (mobile) => {
	return http.request({
		url: 'pad/un_login/send_sms',
		method: 'POST',
		params: {
			'mobile': mobile
		}
	})
}
//上传教师头像
export const uploadTeacher = (filePath) => {
	return http.upload('pad/upload/teacher_head_img', {
		filePath: filePath,
		name: 'file'
	})
}
//上传宝宝头像
export const uploadChildren = (filePath,childrenId) => {
	return http.upload('/wx/api/user/children_head_img/'+childrenId, {
		filePath: filePath,
		name: 'file'
	})
}
//设置默认角色
export const setDefaultStaffRole = (roleId) => {
	return http.request({
		url: '/pad/teacher/set_default_role',
		method: 'POST',
		params: {
			'roleId': roleId
		}
	})
}
//设置默认园区
export const setDefaultStaffArea = (areaId) => {
	return http.request({
		url: '/pad/teacher/change_area',
		method: 'POST',
		params: {
			'areaId': areaId
		}
	})
}
export const getTeacherByStaffId = (staffId) => {
	console.log(staffId);
	return http.request({
		url: '/pad/teacher/info_by_staffId',
		method: 'GET',
		params: {
			'staffId': staffId
		}
	})
}



